
import { _decorator, Component, Node, EventTouch, v3 } from 'cc';
import { Graphics3D } from './Graphics3D';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = g3DTest
 * DateTime = Fri Feb 18 2022 15:30:37 GMT+0800 (中国标准时间)
 * Author = 雨到了1分享
 * FileBasename = g3DTest.ts
 * FileBasenameNoExtension = g3DTest
 * URL = db://assets/graphics3D/script/g3DTest.ts
 * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
 *
 */
 
@ccclass('g3DTest')
export class g3DTest extends Component {
    @property(Graphics3D)
    ctx:Graphics3D = null;

    onLoad(){
        this.node.on(Node.EventType.TOUCH_MOVE,(event:EventTouch)=>{
            let deltaMove = event.touch.getUILocation().subtract(event.touch.getUIPreviousLocation());//获得从startPos指向endPos的方向向量
            let euler1 = v3(this.ctx.node.eulerAngles);
            euler1.x += deltaMove.y/10;
            euler1.y += deltaMove.x/10;
            
            this.ctx.node.eulerAngles = euler1;

        });
    }

    start () {
        this.ctx.moveTo3d(-100,-100,100);
        this.ctx.lineTo3d(-100,100,-100);
        this.ctx.lineTo3d(100,100,100);
        this.ctx.lineTo3d(100,-100,-100);
        this.ctx.lineTo3d(-100,-100,100);
        // this.ctx.close();
        this.ctx.stroke();
        this.ctx.fill();
        
    }

    
}


